package kr.hkit.powerjava.coffee.dto;

public class SalesRecord implements Comparable<SalesRecord> {

	private String pdCode;
	private String pdName;
	private int pdPrice;
	private int amount;
	private double marginRate;
	private int sellingPrice;
	private double tax;
	private int supply;
	private double margin;

	public SalesRecord() {
	}

	public SalesRecord(String pdCode, int pdPrice, int amount, double marginRate) {
		this.pdCode = pdCode;
		this.pdPrice = pdPrice;
		this.amount = amount;
		this.marginRate = marginRate;
	}

	public SalesRecord(String pdCode, String pdName, int pdPrice, int amount,
			double marginRate) {
		this.pdCode = pdCode;
		this.pdName = pdName;
		this.pdPrice = pdPrice;
		this.amount = amount;
		this.marginRate = marginRate;
	}

	public String getPdCode() {
		return pdCode;
	}

	public void setPdCode(String pdCode) {
		this.pdCode = pdCode;
	}

	public String getPdName() {
		return pdName;
	}

	public void setPdName(String pdName) {
		this.pdName = pdName;
	}

	public int getPdPrice() {
		return pdPrice;
	}

	public void setPdPrice(int pdPrice) {
		this.pdPrice = pdPrice;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public double getMarginRate() {
		return marginRate;
	}

	public void setMarginRate(double marginRate) {
		this.marginRate = marginRate;
	}

	public int getSellingPrice() {
		sellingPrice = pdPrice * amount;
		return sellingPrice;
	}

	public int getTax() {
		tax = getSellingPrice() / 11;
		return (int) Math.ceil(tax);
	}

	public int getSupply() {
		supply = (getSellingPrice() - getTax());
		return supply;
	}

	public int getMargin() {
		margin = getSupply() * marginRate;
		return (int) Math.round(margin);
	}

	@Override
	public String toString() {
		return "SalesRecord [pdCode=" + pdCode + ", pdName=" + pdName
				+ ", pdPrice=" + pdPrice + ", amount=" + amount
				+ ", marginRate=" + marginRate + ", getSellingPrice()="
				+ getSellingPrice() + ", getTax()=" + getTax()
				+ ", getSupply()=" + getSupply() + ", getMargin()="
				+ getMargin() + "]";
	}

	@Override
	public int compareTo(SalesRecord o) {
		return this.pdCode.hashCode() - o.pdCode.hashCode();
	}

}
